import request from '@/utils/request'

const API_NAME = '/admin/edu/chapters'

export default {
  // 根据ID获取一个章节
  queryById(id) {
    return request({
      url: `${API_NAME}/${id}`,
      method: 'get'
    })
  },
  // 新增一个章节
  insert(chapter) {
    return request({
      url: `${API_NAME}/`,
      method: 'post',
      data: chapter
    })
  },
  // 修改一个章节
  update(chapter) {
    return request({
      url: `${API_NAME}/`,
      method: 'put',
      data: chapter
    })
  },
  // 根据ID删除章节
  deleteById(id) {
    return request({
      url: `${API_NAME}/${id}`,
      method: 'delete'
    })
  },
  // 获取章节>视频树形列表
  getTreeList(courseId) {
    return request({
      url: `${API_NAME}/tree/${courseId}`,
      method: 'get'
    })
  },
}
